Repository navigation
fix(studio): a sealed preview that can't swap scenes reloads without asking first - #8544
Conversation
Edit accuracy: accurate 271 (base branch 271), smooth 60 of thoseThe gate passes. Quarantined, measured but not gated (0) |
jrusso1020
left a comment
There was a problem hiding this comment.
Verdict: APPROVE at 5976e4e7.
Need ✅ · Size ✅ (+77/−5, about half of it tests) · Reuse ✅ (one timelineMessage builder for both timeline posts; scenesSwappable is the same check that installs __hfSwapScenes) · Simpler ✅ · Structure ✅
Risk: low. A missing or stale answer only costs one reload or one refused swap, and the right film shows either way.
- One source of truth.
scenesSwappableis read once, in the same synchronous init body that later decides whether to install__hfSwapScenes. Both posts of a timeline payload (the first post andonAnnounceTimeline) now go throughtimelineMessage, so no timeline message leaves withoutsceneSwap. - Studio only trusts an explicit "no".
notePreviewSceneSwapstores only booleans, andsealedSwapreturnsnullonly for a storedfalse. An older runtime that sends nothing is still asked, as before. The note happens afteracceptedPreviewMessage, so only the current frame's accepted messages count. - Red-first holds. With main's
init.ts,types.ts,sceneSwap.tsandpreviewMessageRouter.ts, all four named tests fail (1 in core, 3 in studio). At this head,init.swapScenes.test.tspasses 171/171 andpackages/studio/src/playerpasses 2683/2683, both run locally.
Nit: the answer is keyed by the frame element, so it outlives a load until that load's first timeline message, which the body says. A comment at sceneSwapAnswers saying so would keep the next reader from "fixing" it per load.
— Rames (hf-review)
What
On a sealed preview whose film has no scene manifest, an edit that needs a full refresh now reloads at once. Before, Studio first fetched the whole preview document and asked the frame to swap scenes. The frame always refused ("the preview cannot swap scenes"), and only then did the reload start, 0.1-0.5 s late.
Why
refreshPlayeraskssceneSwapFor(iframe)whether the preview can swap, and reloads directly when it can't.reachableSwapreads the frame's__hfSwapScenes. The runtime sets that only when the preview has a scene manifest, so a film without one getsnulland reloads at once.sealedSwapalways returned a swap. Every refresh of such a film fetched the preview HTML, sentswap-scenes, and waited for the refusal.On the edit-accuracy bench, 12 sequences at 3 parallel jobs, 3 runs per mode:
Related work
Refs #7846 (Studio's preview sealed by default). Found while measuring how long a sealed undo takes to show; #8542 makes the bench record that time.
How
init.ts): onetimelineMessagebuilder makes every timeline message the runtime posts, the first post and each later announce. It addssceneSwap, true only when the preview has a scene manifest. That's the same value that decides whether__hfSwapScenesis installed, now read once intoscenesSwappable. It's sent per load on the timeline message, not inRUNTIME_PROTOCOL_CAPABILITIES, which is the same for every document a runtime build serves.sceneSwap.ts):notePreviewSceneSwapkeeps each frame's latest answer, and the message router calls it on every timeline message.sealedSwapreturnsnullonly when the frame saidfalse. An older runtime that sends nosceneSwapis still asked, so no swap a frame could do is lost.No visible change
On a sealed preview without scenes, the film reloads a little sooner after an edit that needs it. The interface itself doesn't change.
Test plan
fails without the fix:
packages/core/src/runtime/init.swapScenes.test.ts: "says in each timeline message whether this load can swap scenes";packages/studio/src/player/sceneSwap.sealed.test.ts: "asks no swap of a sealed load that said it cannot swap, so the film reloads at once";packages/studio/src/player/hooks/previewMessageRouter.clipFields.test.ts: "takes each load's word on whether it can swap scenes"."still asks a load that said it can swap, and an older runtime that said nothing" fails on main only because
notePreviewSceneSwapdoesn't exist there; it pins that an older runtime is still asked.Against main's
init.ts,types.ts,sceneSwap.tsandpreviewMessageRouter.ts, all four rows fail. With the fix,init.swapScenes.test.ts(171 tests) andsceneSwap.sealed.test.ts,sceneSwap.test.tsandpreviewMessageRouter.clipFields.test.ts(20 tests) pass three runs in a row on Linux.